﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.DataSourcesFile;
//using ESRI.ArcGIS.DataSourcesFile;


/// <summary>
/// Workspace 的摘要说明
/// </summary>
public class Workspace
{
	public Workspace()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
    }

    public static IWorkspace getSdeWorkspace()
    {
        IWorkspaceFactory pWF = new SdeWorkspaceFactoryClass();
        IPropertySet pProSet = new PropertySetClass();
        pProSet.SetProperty("Server", "192.168.2.51");
        pProSet.SetProperty("Instance", "port:5151");
        pProSet.SetProperty("Database", "");
        pProSet.SetProperty("User", "ct");
        pProSet.SetProperty("Password", "xjct");
        pProSet.SetProperty("Version", "sde.DEFAULT");
        IWorkspace pWS = pWF.Open(pProSet, 0);
        return pWS;
    }

    public static IWorkspace getSdeWorkspace(string sServer, string sInstance, string sDB, string sUser, string sPasswd, string sVersion)
    {
        IWorkspaceFactory pWF = new SdeWorkspaceFactoryClass();
        IPropertySet pProSet = new PropertySetClass();
        pProSet.SetProperty("Server", sServer);
        pProSet.SetProperty("Instance", sInstance);
        pProSet.SetProperty("Database", sDB);
        pProSet.SetProperty("User", sUser);
        pProSet.SetProperty("Password", sPasswd);
        pProSet.SetProperty("Version", sVersion);
        IWorkspace pWS = pWF.Open(pProSet, 0);
        return pWS;
    }

    public static IFeatureWorkspace getShapeFileWorkspace(string FilePath)
    {
        IWorkspaceFactory pWPF = new ShapefileWorkspaceFactoryClass();
        IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWPF.OpenFromFile(FilePath, 0);
        return pFeatureWorkspace;
    }

}
